package SHGui;


import javax.imageio.ImageIO;
import javax.swing.*;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.GridBagLayout;
import java.awt.BorderLayout;
import java.awt.Image;

import javax.swing.GroupLayout.Alignment;

import java.awt.Color;

import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.event.AncestorListener;

import org.w3c.dom.events.EventTarget;
import org.w3c.dom.events.MouseEvent;
import org.w3c.dom.views.AbstractView;

import SHClient.Button1;
import SHClient.ListVar;
import SHClient.Main;
import SHClient.Product_Ctrl;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.awt.GridLayout;
import java.awt.Button;
public class URoom_GUI extends JPanel implements ActionListener {
	
	public static ArrayList<Button1> arr = new  ArrayList<Button1>();
	public JLabel NameLbl;
	String g="";
	public JButton btnBack=null;
	public URoom_GUI (){
		setLayout(null);
		}	
	
	public URoom_GUI (String[] str) throws IOException {
		btnBack = new JButton("\u05D7\u05D6\u05D5\u05E8");
		btnBack.setBounds(351, 266, 89, 23);
		add(btnBack);
		this.btnBack.addActionListener(this);
	   	g=str[1];
		this.setLayout(new FlowLayout());
		for (int i=2;i<Integer.parseInt(str[1]);)
		{
			JButton temp= new JButton();
			temp.setText(str[i+3]);
			Button1 b1 = new Button1(temp,str[i+2],str[i+1],str[i]);
			arr.add(b1);
			this.add(b1.b);
			b1.b.addActionListener(this);
			i+=4;
		}
		this.setBackground(Color.blue);
	}
	public void actionPerformed(ActionEvent e) {
		JButton src = (JButton)e.getSource();
		for(int i=0; i<arr.size();i++){
			try{
		if(src==arr.get(i).b){
			Main.pc.showGui(arr.get(i).id , arr.get(i).type ,  arr.get(i).image);//id,type,image
		}}	catch (Exception ex){}
		 
			
		}
		
	}
		}


